<?php

$router = new \Phalcon\Mvc\Router(false);

$router->removeExtraSlashes(true);

$router->add('/:controller/([a-zA-Z0-9_\-]+)/:params', array(
    'controller' => 1,
    'action'     => 2,
    'params'     => 3,
))->convert('action', function ($action) {

    if(stripos($action,'-') === false && stripos($action,'_') === false){
        return lcfirst($action);
    }
    return lcfirst(Phalcon\Text::camelize($action,"-_"));
})->convert('controller',function ($controller){
    if(stripos($controller,'-') === false && stripos($controller,'_') === false){
        return ucfirst($controller);
    }

    return ucfirst(Phalcon\Text::camelize($controller,'-_'));
});

$router->add('/:controller', array(
    'controller' => 1,
    'action' => 'index'
))->convert('controller',function ($controller){
    if(stripos($controller,'-') === false && stripos($controller,'_') === false){
        return ucfirst($controller);
    }

    return ucfirst(Phalcon\Text::camelize($controller,'-_'));
});

$router->mount(new \Cuke\Http\Router\GroupRoutes());
$router->mount(new \Cuke\Http\Router\ConnectorRoutes());

//网关入口
$router->add('/gateway.do',array(
    'controller' => 'Gateway',
    'action'     => 'index'
));

$router->add('/',array(
    'controller' => 'Home',
    'action' => 'index'
))->setName('home.index');

return $router;